<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<title>激活卡统计报表</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp"%>
<script src="js/getCardPermission.js" type="text/javascript"></script>
<link rel="stylesheet" href="<%=path%>/css/zTreeStyle/zTreeStyle.css">
<%@ include file="/WEB-INF/jsp/common/common.jsp"%>
<script type="text/javascript" src="<%=path%>/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.ztree.excheck-3.5.js"></script>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<style type="text/css">
.input_btn_box {
    text-align: center;
    padding-top: 20px;
}
</style>
<script type="text/javascript">
//-------------------- init--------------------------- start
//获取url中的参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}
$(function () {
	// 查询数据
	setDetailsData(1)
})
//-------------------- init--------------------------- end
function setDetailsData(current) {
	var deptNo = getUrlParam('deptNo')
    var IdStr = getUrlParam('IdStr') 
    if (deptNo.length >= 8) {
    	$.message("error", "暂无下级机构");
    	return
    }
    queryDetails({current: current,size:10,deptNo: deptNo,IdStr: IdStr})
}
/* 查询详情 */
function queryDetails(param) {
	$.openLoading();
	var jsonDate;
    if(null != param && null != param.current){
        jsonDate =param;    
    }else{
        jsonDate={current:1,size:10};
    }
	$.ajax({
        url : "cardreport/queryDetails",
        type : 'POST',
        async : true,
        dataType:'json',
        data: param,
        success : function(page) {
        	$.closeLoading();
        	if (page.result != 'success') {
        		$.message("error", page.message);
                return;
        	}
        	if(page.data.length==0){
                $.message("error", "暂未查到数据");
                return;
            }
        	
            startP = page.current;
            // var fieldNames = "deptNo,name,sumFrame,modalPremamtPp,notCommamt,yesCommamt,yesApp,wckMoney,yckMoney,yappMoney,id@TDH";
            
            /* var lastColumnFunction = function (val) {
                if (val.isDetail == '1') {
                    return "<input type='button' class='input_button_1' value='详情' onClick='queryDetail(this)' />";
                } else {
                    return "<input type='button' class='input_button_1' value='返回' onClick='goBack(this)' />";
                }
            } */
            
            /* var lastColumnFunction = function (val) {
                return "<input type='button' class='input_button_1' value='详情' onClick='queryDetail(this)' />";
            } */
            
            // var firstColumnElement= null;
            
            // var tableContent = creatTable4(fieldNames, page,firstColumnElement,lastColumnFunction);
            /* var tableContent = ''
            $.each(page.data, function (i, v) {
            	tableContent += '<tr><td>' + v.deptNo
                              + '</td><td>' + v.name
                              + '</td><td>' + v.sumFrame
                              + '</td><td>' + v.modalPremamtPp
                              + '</td><td>' + v.notCommamt
                              + '</td><td>' + v.yesCommamt
                              + '</td><td>' + v.yesApp
                              + '</td><td>' + v.notCommamt * v.modalPremamtPp
                              + '</td><td>' + v.yesCommamt * v.modalPremamtPp
                              + '</td><td>' + v.yesApp * v.modalPremamtPp
                              + '</td><td style="display: none;">' + v.id
                              + '</td><td><input type="button" class="input_button_1" value="详情" onClick="queryDetail(this)" /></td></tr>'
            })
            
            var tableObj = $("#detailsTable");
            tableObj.find("tbody").remove();
            tableObj.append(tableContent);
            
            var strPage = creatChannelPage(startP,6,page.maxPage,"80");
            var pageDIV = $("#detailsPageDIV");
            pageDIV[0].innerHTML="";
            pageDIV.append(strPage); */
            var fieldNames = "deptNo,name,sumFrame,modalPremamtPp,notCommamt,yesCommamt,yesApp,yesDiscard,wckMoney,yckMoney,yappMoney,ydiscardMoney,id@TDH";
            var lastColumnElement ="<input type='button' class='input_button_1' value='详情' onClick='queryDetail(this)' />";
            var firstColumnElement= null;
            var tableContent = creatTable1(fieldNames, page,firstColumnElement,lastColumnElement);
            var tableObj = $("#detailsTable");
            tableObj.find("tbody").remove();
            tableObj.append(tableContent);
            
            var strPage = creatChannelPage(startP,6,page.maxPage,"81");
            var pageDIV = $("#detailsPageDIV");
            pageDIV[0].innerHTML="";
            pageDIV.append(strPage);
        }
    })
}
/* 点击详情按钮 */
function queryDetail(obj) {
	
    var deptNo = $(obj).parent().parent().children()[0].innerText.split('-')[0].trim()
    if(deptNo.length>=8){
        $.message("error", "暂无下级机构");
        return;
    }
    
    var IdStr = $(obj).parent().parent().children()[12].innerText 
	// 查询详情页面
    self.location.href="<%=path%>/cardreport/details?deptNo=" + deptNo + "&IdStr=" + IdStr
}
/* 点击收起按钮 */
function goBack(obj) {
	var deptNo = getUrlParam('deptNo')
	var IdStr = getUrlParam('IdStr') 
	// var deptNo = $(obj).parent().parent().children()[0].innerText.split('-')[0]
	if (deptNo.length > 2) {
		deptNo = deptNo.slice(0, deptNo.length-2)
		// var IdStr = $(obj).parent().parent().children()[10].innerText 
	    // 查询详情页面
	    self.location.href="<%=path%>/cardreport/details?deptNo=" + deptNo + "&IdStr=" + IdStr
	} else {
		// 报表主页面
		self.location.href="<%=path%>/cardreport/index"
	}
}
//-------------------- init--------------------------- end
</script>
</head>
<body>
    <div class="current">
        <table class="current_table_1">
            <tbody>
                <tr class="f2">
                    <td><img src="./images/current_1.jpg"></td>
                    <td class="current_table_1_td"><img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                        <span style="color: #136bab;">激活卡管理 <span
                            style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>
                            激活卡统计报表
                    <span style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>
                            激活卡统计报表详情
                    </span></td>
                    <td><img src="./images/current_3.jpg"></td>
                </tr>
            </tbody>
        </table>
    </div>

    <table class="table_02" id="table">
        <!-- 数据列表 start -->
        <tr>
            <td>
	            <div class="table_box ">
	                <table id="detailsTable" class="content_table_1">
	                    <thead>
	                        <tr class="f1">
	                                <th style="width: 6%">机构</th>
	                                <th style="width: 5%">卡定义名称</th>
	                                <th style="width: 3%">总数</th>
	                                <th style="width: 3%">每单保费</th>
	                                <th style="width: 3%">未出库数</th>
	                                <th style="width: 3%">可激活数</th>
	                                <th style="width: 3%">已激活数</th>
                                    <th style="width: 3%">作废数</th>
	                                <th style="width: 3%">未出库金额</th>
	                                <th style="width: 3%">可激活金额</th>
	                                <th style="width: 3%">已激活金额</th>
                                    <th style="width: 3%">作废金额</th>
	                                <th style="width: 2%">操作</th>
	                        </tr>
	                    </thead>
	                    <tbody>
	                    </tbody>
	                </table>
	                <div id="detailsPageDIV" class="page"></div>
                </div>
            </td>
        </tr>
        <!-- 数据列表 end -->
    </table>
    <div class="input_btn_box">
        <input type='button' class='input_button_1' value='返回' onClick='goBack(this)' />
    </div>
</body>
</html>